﻿var hover, lightbox, slider = false;
var o = {
    init: function () {
        this.hover.init();
        this.lightbox.init();
        this.slider.init();
    },
    hover: {
        init: function () {
            var images = $('#gallery img');
            images.animate({
                "opacity": .5
            });

            images.hover(function () {
                $(this).stop().animate({
                    "opacity": 1,
                });
            }, function () {
                $(this).stop().animate({
                    "opacity": .5
                });
            });
        }
    },
    lightbox: {
        init: function() {
            $("a[rel=photo_group]").fancybox({
                'transitionIn': 'none',
                'transitionOut': 'none',
                'titlePosition': 'over',
                'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                }      
                });                  
        }
    },
    slider : {
        init: function() {
            var conveyor = $('.content-conveyor', $('#sliderContent')),
            item = $('.item', $('#sliderContent'));
            conveyor.css("width", item.length * parseInt(item.css('width')));
            var sliderOpts = {
                max: (item.length * parseInt(item.css('width'))) - parseInt($('.view', $('#sliderContent')).css('width')),
                slide: function (e, ui) {
                    conveyor.css('left', '-' + ui.value + 'px');
                }
            };
            $('#slider').slider(sliderOpts);
        }
    }
}

$(function () {
    o.init();
});          